#ifndef TRANSFORMTOOL_H
#define TRANSFORMTOOL_H
#include <QPolygon>
#include "AbstractTool.h"
#include "TransformAction.h"



class TransformTool : public AbstractTool
{

  Q_OBJECT

private:

  QPolygon _origControlBox;
  QPolygon _curControlBox;
  Ptr< SelectRegion > _pCurSelection;
  Ptr< SelectRegion > _pOrigSelection;

  Ptr< TransformAction > _pAction;


  bool _isTransformStart;
  bool _isTranslateStart;
  bool _isRotateStart;
  bool _isScaleStart;

  QPoint _origMouseLoc;
  TransformState _origTrans;



  void _transformControlBox ();



  virtual void _canvasPaintingEvent (QPainter & painter);

  virtual void _canvasMousePressedEvent (QPoint loc, QMouseEvent * event);

  virtual void _canvasMouseMovedEvent (QPoint loc, QMouseEvent * event);

  virtual void _canvasMouseReleasedEvent (QPoint loc, QMouseEvent * event);

  virtual void _startEvent ();

  virtual void _finishEvent ();



  void _startTransform ();

  void _finishTransform ();

  void _cancelTransform ();



  void _doTranslate (const QPoint & loc);

  void _doRotate (const QPoint & loc);

  void _doScale (const QPoint & loc);



  void _updateMousePoint (const QPoint & point);

  bool _isOnControlCorner (const QPoint & point);

public:

  TransformTool (QWidget * parent);
  ~TransformTool ();

};

#endif // TRANSFORMTOOL_H
